package com.k2data.k2app.domain.po;

import com.k2data.k2app.domain.vo.Device;
import com.k2data.k2app.domain.vo.LabelValueKeyObject;
import com.k2data.k2app.domain.vo.LabelValueObject;
import com.k2data.k2app.domain.vo.Model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.Transient;
import java.util.List;
import java.util.Map;

/**
 * 设备分析任务
 * [和数据库表对应,关联设备]
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskDTO extends TaskDO {

    @Transient
    List<Device> device;
    /**
     * 模型
     */
    @Transient
    private Model model;
    /**
     * 结果通知
     */
    @Transient
    private String[] actions;

    @Transient
    private LabelValueKeyObject devicePart;

    @Transient
    private LabelValueObject deviceTypeJson;

    @Transient
    private LabelValueKeyObject customer;

    //测点变量
    @Transient
    List<LabelValueKeyObject> varData;
    //计算量 测点变量
    @Transient
    LabelValueKeyObject  varDataCalculate;

    // fieldGroup
    String fieldGroupId;

    List<String> deviceIds;
    List<String> channelIds;

    // 测点信息
    Map Point;
    // 测点信息
    Map PointCalculate;
    // 通道信息
    Map channel;

    /**
     * 频率的单位
     */
    @Transient
    String prefix;

    public void setFre(){
        String p = "m";
        if(getPrefix() != null) {
            switch (getPrefix()){
                case "minute":
                    p = "m";
                    break;
                case "分钟":
                    p = "m";
                    break;
                case "小时":
                    p = "h";
                    break;
                case "hour":
                    p = "h";
                    break;
                case "天":
                    p = "d";
                    break;
                case "day":
                    p = "d";
                    break;
                case "month":
                    p = "mo";
                    break;
                case "月":
                    p = "mo";
                    break;
                default:
                    p = "m";
                    break;
            }
        }
        setFrequency(getFrequency()+"_"+p);
    }
}